using System;
using System.Collections.Generic;
using System.Text;

namespace RideMe.Core.SortableCollection
{
    public class SortableCollection<T> : System.Collections.CollectionBase
    {
        public virtual T this[int index]
        {
            get { return (T)this.List[index] ; }
            set { this.List[index] = value ; }
        }
      
        public virtual int IndexOf(T item)
        {
            return this.List.IndexOf(item) ;
        }

        public virtual int Add(T item)
        {
            return this.List.Add(item) ;
        }

        public virtual void Remove(T item)
        {
            this.List.Remove(item) ;
        }

        public virtual void CopyTo(Array array, int index)
        {
            this.List.CopyTo(array, index) ;
        }

        public virtual void AddRange(SortableCollection<T> collection)
        {
            this.InnerList.AddRange(collection) ;
        }

        public virtual void AddRange(T[] collection)
        {
            this.InnerList.AddRange(collection) ;
        }

        public virtual bool Contains(T item)
        {
            return this.List.Contains(item) ;
        }

        public virtual void Insert(int index, T item)
        {
            this.List.Insert(index, item) ;
        }

        public void Sort(string sortExpression, SortDirection sortDirection)
        {
            InnerList.Sort(new Comparer(sortExpression, sortDirection));
        }

        public void Sort(string sortExpression)
        {
            InnerList.Sort(new Comparer(sortExpression));
        }
    }
}
